package com.hyts.serialize.binary;


import lombok.Getter;
import lombok.Setter;

/**
 * project-name:coffice-toolbox
 * package-name:com.hyts.serialize.handler
 * author:Libo/Alex
 * create-date:2019-06-21 20:56
 * copyright:libo-hyts-github
 * email:libo2dev@aliyun.com
 * description:此类主要用于: 字节二进制序列化处理器
 */
public abstract class BinarySerializeHandler<P,R> implements SerializeHandler<Object,byte[]>{

    /**
     * 结果对象
     */
    @Setter
    @Getter
    private R result;

    /**
     * 构建对象
     * @return
     */
    public abstract BinarySerializeHandler<P,R> build();

    /**
     * 构建对象
     * @return
     */
    public abstract BinarySerializeHandler<P,R> build(P param);

    /**
     * 反序列化
     * @param byteData
     * @param clazzType
     * @return
     */
    public abstract <T> T deserialize(byte[] byteData,Class<T> clazzType);

    /**
     * 序列化
     * @param data
     * @param clazzType
     * @return
     */
    public abstract <T> T serialize(T data,Class<T> clazzType);


}
